revealer: Request child size for NONE transition type
authorTimm Bäder <mail@baedert.org>
Sun, 4 Jun 2017 16:33:08 +0000 (18:33 +0200)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 20 Jul 2017 01:27:13 +0000 (21:27 -0400)
Previously, we would request a size of 0×0 when the transition type was
NONE and the child un-revealed, making the revealer in this case a
gtk_widget_set_visible replacement. Instead, to the exact same thing we
do in the CROSSFADE case and request the child size instead. This also
keeps the revealer from under allocating the child when the transition
type is set to NONE.

gtk/gtkrevealer.c
testsuite/gtk/revealer-size.c

index 32b87cdc56695f3927b1b1ff8eb57fd7e7b915af..2dbe9c4a2b539ccd32c3813aa039dbe123192bbc 100644 (file)
@@ -385,10 +385,17 @@ gtk_revealer_set_position (GtkRevealer *revealer,
   child = gtk_bin_get_child (GTK_BIN (revealer));
   if (child != NULL &&
       new_visible != gtk_widget_get_child_visible (child))
-    gtk_widget_set_child_visible (child, new_visible);
+    {
+      gtk_widget_set_child_visible (child, new_visible);
+      gtk_widget_queue_resize (GTK_WIDGET (revealer));
+    }
 
   transition = effective_transition (revealer);
-  if (transition == GTK_REVEALER_TRANSITION_TYPE_CROSSFADE)
+  if (transition == GTK_REVEALER_TRANSITION_TYPE_NONE)
+    {
+      gtk_widget_queue_draw (GTK_WIDGET (revealer));
+    }
+  else if (transition == GTK_REVEALER_TRANSITION_TYPE_CROSSFADE)
     {
       gtk_widget_set_opacity (GTK_WIDGET (revealer), priv->current_pos);
       gtk_widget_queue_draw (GTK_WIDGET (revealer));
@@ -550,8 +557,7 @@ set_height (GtkRevealer *revealer,
   GtkRevealerTransitionType transition;
 
   transition = effective_transition (revealer);
-  if (transition == GTK_REVEALER_TRANSITION_TYPE_NONE ||
-      transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP ||
+  if (transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP ||
       transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN)
     {
       *minimum_height = round (*minimum_height * priv->current_pos);
@@ -568,8 +574,7 @@ set_width (GtkRevealer *revealer,
   GtkRevealerTransitionType transition;
 
   transition = effective_transition (revealer);
-  if (transition == GTK_REVEALER_TRANSITION_TYPE_NONE ||
-      transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT ||
+  if (transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT ||
       transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT)
     {
       *minimum_width = round (*minimum_width * priv->current_pos);
index fefae48b73a0cac09718a7c1c7ba015d39464d8d..4fbea9cf19f4f940ef8c1bb0742995e4ae94f3fd 100644 (file)
@@ -85,13 +85,13 @@ slide_left_no_animations ()
 static void
 none_animations ()
 {
-  keep_size (0, GTK_REVEALER_TRANSITION_TYPE_NONE, TRUE);
+  keep_size (KEEP_WIDTH | KEEP_HEIGHT, GTK_REVEALER_TRANSITION_TYPE_NONE, TRUE);
 }
 
 static void
 none_no_animations ()
 {
-  keep_size (0, GTK_REVEALER_TRANSITION_TYPE_NONE, FALSE);
+  keep_size (KEEP_WIDTH | KEEP_HEIGHT, GTK_REVEALER_TRANSITION_TYPE_NONE, FALSE);
 }
 
 static void